package com.my.core.domain.exception;

import com.my.core.api.ResultCode;

/**
 * @author timo 2021/3/31
 */
public class SecureException extends RuntimeException {
    private final ResultCode resultCode;

    public SecureException(String message) {
        super(message);
        this.resultCode = ResultCode.UN_AUTHORIZED;
    }

    public SecureException(ResultCode resultCode) {
        super(resultCode.getMessage());
        this.resultCode = resultCode;
    }

    public SecureException(ResultCode resultCode, Throwable cause) {
        super(cause);
        this.resultCode = resultCode;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }

    public Throwable doFillInStackTrace() {
        return super.fillInStackTrace();
    }

    public ResultCode getResultCode() {
        return this.resultCode;
    }
}
